<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
    <meta name="renderer" content="webkit">
    <meta name="keywords" content="{$navCur.keywords}"/>
    <meta name="description" content="{$navCur.description}"/>
    <title>{$navCur.seotitle} - {$site.site_name}</title>
    <link rel="stylesheet" type="text/css" href="__CDN__/assets/addons/wwh/css/swiper.min.css">
    <link rel="stylesheet" type="text/css" href="__CDN__/assets/addons/wwh/css/animate.min.css">
    <link rel="stylesheet" type="text/css" href="__CDN__/assets/addons/wwh/css/style.css">
    <link rel="stylesheet" type="text/css" href="__CDN__/assets/addons/wwh/css/media.css">
    <script type="text/javascript" src="__CDN__/assets/addons/wwh/js/jquery.min.js"></script>
    <script type="text/javascript" src="__CDN__/assets/addons/wwh/js/swiper.min.js"></script>
    <script type="text/javascript" src="__CDN__/assets/addons/wwh/js/swiper.animate1.0.3.min.js"></script>
    <script type="text/javascript" src="__CDN__/assets/addons/wwh/js/wow.js"></script>
    <script type="text/javascript" src="__CDN__/assets/addons/wwh/js/menu.js"></script>
    <script type="text/javascript" src="__CDN__/assets/addons/wwh/js/javascript.js"></script>
    <link rel="shortcut icon" href="__CDN__/assets/addons/wwh/images/favicon.ico">
</head>
<style>
    .upload .input input[type="file"]{
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        opacity: 0;
    }
</style>
<body>
<!--头部-->
{include file="header" /}
<!-- 栏目Banner -->
<div class="col-banner">
    <div class="text">
        <div class="title wow fadeInUp" data-wow-delay="0.3s">
            <h3>{$site.ban5_t1}</h3><i></i>
        </div>
    </div>
    <div class="img">
        <div class="pic" style="background-image: url('{$site.banner5|cdnurl}');">
            <img src="__CDN__/assets/addons/wwh/images/col_size.png" class="img-block" alt="">
        </div>
    </div>
    <div class="banner-path wow fadeInLeft" data-wow-delay="0.4s">
        <div class="container-outer">
            <div class="icon"><img src="__CDN__/assets/addons/wwh/images/home.svg" class="img-center"></div>
            <div class="link">
                <a href="{:addon_url('wwh/index/index')}">{:__lang('Home')}</a>
                <span>/</span>
                <a href="{:addon_url('wwh/column/index', [':diyname'=>$top.diyname])}">{if condition="($navCur.parent_id == '0')"} {$navCur.name} {else /} {$top.name} {/if}</a>
                <span>/</span>
                <a href="{:addon_url('wwh/column/index', [':diyname'=>$navCur.diyname])}" class="cur">{$navCur.name}</a>
            </div>
        </div>
    </div>
</div>
<!-- 内容 -->
<div class="join-detail">
    <div class="container-outer">
        <div class="join-box">
            <div class="top">
                <form method="get" action="" class="clearfix">
                    <div class="join-option">
                        <div class="dept wow fadeInUp" data-wow-delay="0.5s">
                            <select name="branch" id="branch">
                                <option value="" selected>{:__lang('All Sectors')}</option>
                                {volist name="deptList" id="v"}
                                <option value="{$v.dept}">{$v.dept}</option>
                                {/volist}
                            </select>
                        </div>
                        <div class="add wow fadeInUp" data-wow-delay="0.6s">
                            <select name="address" id="address">
                                <option value="" selected>{:__lang('Work Location')}</option>
                                {volist name="addrList" id="v"}
                                <option value="{$v.addr}">{$v.addr}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="join-search wow fadeInUp" data-wow-delay="0.7s">
                        <div class="so-inp">
                            <input type="text" value="" name="jonKeywords" id="jonKeywords" placeholder="{:__lang('Search for job positions')}" />
                        </div>
                        <input type="submit" value="" class="join-button" />
                    </div>
                </form>
            </div>
            <div class="bottom">
                {volist name="join" id="v"}
                <div class="join-item wow fadeInUp" data-wow-delay="0.8s">
                    <div class="recruit-top">
                        <div class="recruit-top-box clearfix">
                            <div class="recruit-top-left">
                                <div class="psn">
                                    <p>{$v.name}</p>
                                </div>
                            </div>
                            <div class="recruit-top-right clearfix">
                                <div class="req">
                                    <p>{$v.dept}</p>
                                </div>
                                <div class="req">
                                    <p>{$v.addr}</p>
                                </div>
                                <div class="req">
                                    <p>{$v.num}</p>
                                </div>
                                <div class="req">
                                    <p>{$v.xueli}</p>
                                </div>
                                <div class="req">
                                    <p>{$v.time}</p>
                                </div>
                            </div>
                            <div class="drop-box">
                                <div class="drop-img">
                                    <img src="__CDN__/assets/addons/wwh/images/down_arrow1.svg" alt="" class="drop-ico1">
                                    <img src="__CDN__/assets/addons/wwh/images/down_arrow2.svg" alt="" class="drop-ico2">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="recruit-content">
                        <p>{$v.content}</p>
                        <a href="javascript:;" class="join-more" onclick="showForm(this.name)" name="{$v.name}">{:__lang('Apply Now')}</a>
                    </div>
                </div>
                {/volist}
            </div>
        </div>
    </div>
</div>
<div class="fenye wow fadeInUp" data-wow-delay="0.8s">{$joinPage}</div>
<!--底部-->
{include file="footer" /}
<script>	
    function showForm(e) {
        // 安全转义输入值
        var escapedE = $('<div/>').text(e).html();

        // 使用数组join方式构建HTML字符串
        var htmlParts = [
            '<form id="resume" method="post" class="join-form">',
            '    <div class="title">{:__lang("Welcome to join us")}</div>',
            '    <div class="message-text"><input type="text" placeholder="{:__lang("Full Name")}" name="realname2" id="realname2" autocomplete="name" maxlength="50"></div>',
            '    <div class="message-text"><input type="tel" placeholder="{:__lang("Contact Number")}" name="tel2" id="tel2" autocomplete="tel" maxlength="20"></div>',
            '    <div class="message-text"><input type="text" placeholder="{:__lang("Post")}" name="gangwei2" id="gangwei2" value="' + escapedE + '" readonly style="background-color: #eeeeee;cursor: not-allowed;"></div>',
            '    <div class="upload">',
            '        <div class="text"><strong>{:__lang("Upload Resume")}*</strong><span>{:__lang("Support")} word、excel、pdf、ppt</span></div>',
            '        <div class="input">',
            '            <span id="file_name"></span>',
            '            <div class="right">',
            '                <span>{:__lang("Upload")}</span>',
            '                <input type="file" name="url" id="url" onchange="changeFile(this)" accept=".doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf">',
            '            </div>',
            '        </div>',
            '    </div>',
            '    <div class="validate">',
            '        <div class="message-text"><input type="text" placeholder="{:__lang("Verification code")}" name="verify2" id="verify2" autocomplete="off"></div>',
            '        <img id="verifyImgs2" class="verify-img" src="{:addon_url("wwh/index/verify")}" onclick="this.src=\'{:addon_url("wwh/index/verify")}?seed=\'+Math.random()">',
            '    </div>',
            '    <div class="resume-subbox"><button type="submit" class="resume-submit">{:__lang("Submit")}</button></div>',
            '    {:token()}',
            '</form>'
        ];

        var html = htmlParts.join('');

        var formLayer = layer.open({
            type: 1,
            title: false,
            closeBtn: 1,
            shadeClose: false,
            anim: 1,
            area: ['auto', 'auto'],
            content: html,
        });

        // 表单submit事件
        $(document).on('submit', '#resume', function(event) {
            event.preventDefault();

            var form = this;
            var formdata = new FormData(form);
            var realname2 = $.trim($("#realname2").val());
            var tel2 = $.trim($("#tel2").val());
            var gangwei2 = $.trim($("#gangwei2").val());
            var url = $.trim($("#url").val());
            var verify2 = $.trim($("#verify2").val());

            // 验证逻辑
            if (!realname2) {
                layer.alert('{:__lang(\'Please fill in your name\')}', {skin: 'layui-layer-lan', closeBtn: 0, title: "{:__lang(\'Tips\')}：", icon: 2, anim: 2});
                return false;
            }

            if (!tel2) {
                layer.alert('{:__lang(\'Please provide your phone number\')}', {skin: 'layui-layer-lan', closeBtn: 0, title: "{:__lang(\'Tips\')}：", icon: 2, anim: 2});
                return false;
            }

            if (!/^1[3-9]\d{9}$/.test(tel2)) {
                layer.alert('{:__lang(\'Please provide a valid phone number\')}', {skin: 'layui-layer-lan', closeBtn: 0, title: "{:__lang(\'Tips\')}：", icon: 2, anim: 2});
                return false;
            }

            if (!gangwei2) {
                layer.alert('{:__lang(\'Please select the position to apply for\')}', {skin: 'layui-layer-lan', closeBtn: 0, title: "{:__lang(\'Tips\')}：", icon: 2, anim: 2});
                return false;
            }

            if (!url) {
                layer.alert('{:__lang(\'Please upload your resume\')}', {skin: 'layui-layer-lan', closeBtn: 0, title: "{:__lang(\'Tips\')}：", icon: 2, anim: 2});
                return false;
            }

            if (!verify2) {
                layer.alert('{:__lang(\'Please fill in the verification code\')}', {skin: 'layui-layer-lan', closeBtn: 0, title: "{:__lang(\'Tips\')}：", icon: 2, anim: 2});
                return false;
            }

            // 显示加载状态
            var submitBtn = $(form).find('.resume-submit');
            submitBtn.prop('disabled', true).text('{:__lang("Submitting...")}');

            $.ajax({
                url: "{:addon_url('wwh/index/injoin')}",
                type: "POST",
                data: formdata,
                cache: false,
                contentType: false,
                processData: false,
                dataType: "json",
                complete: function() {
                    submitBtn.prop('disabled', false).text('{:__lang("Submit")}');
                },
                success: function(mes) {
                    if (mes.code === 1) {
                        layer.alert(mes.msg || "{:__lang(\'Submitted Successfully\')}", {
                            skin: 'layui-layer-lan',
                            closeBtn: 0,
                            icon: 1,
                            end: function() {
                                layer.close(formLayer);
                                window.location.reload();
                            }
                        });
                    } else {
                        layer.alert(mes.msg || '{:__lang(\'Operation failed, please try again\')}', {
                            skin: 'layui-layer-lan',
                            closeBtn: 0,
                            title: "{:__lang(\'Tips\')}：",
                            icon: 2,
                            anim: 2
                        });
                        $('#verifyImgs2').attr('src', '{:addon_url("wwh/index/verify")}?seed=' + Math.random());
                    }
                },
                error: function() {
                    layer.alert('{:__lang(\'Network error, please try again\')}', {
                        skin: 'layui-layer-lan',
                        closeBtn: 0,
                        title: "{:__lang(\'Tips\')}：",
                        icon: 2,
                        anim: 2
                    });
                    $('#verifyImgs2').attr('src', '{:addon_url("wwh/index/verify")}?seed=' + Math.random());
                }
            });
        });
    }

    function changeFile(obj) {
        var fileName = $(obj).val().split('\\').pop();
        if (fileName.length > 50) {
            fileName = fileName.substring(0, 50) + '...';
        }
        $("#file_name").text(fileName);
    }
</script>
<script type="text/javascript">
    $(function () {
        $(".join-item .recruit-top").click(function(){
            $(this).siblings(".recruit-content").slideToggle();
            $(this).parents().siblings().find(".recruit-content").slideUp();
            $(this).parent().toggleClass("on");
            $(this).parent().siblings().removeClass("on");
        })
    });
</script>
</body>
</html>
